unit AfterDownload_ActionForm;

interface

uses
  AfterDownload_Defines,
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, JvToolEdit, StdCtrls, Buttons, Mask, JvExMask, ExtCtrls,
  JvExControls, JvGroupHeader, JvBaseDlg, JvSelectDirectory;

type
  TAD_ActionForm = class(TForm)
    RB_Copy: TRadioButton;
    RB_Move: TRadioButton;
    RB_Launch: TRadioButton;
    E_Param: TEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    FE_Launch: TJvFilenameEdit;
    Label1: TLabel;
    CBX_Category: TComboBox;
    RB_Start: TRadioButton;
    CB_Wait: TCheckBox;
    CB_First: TCheckBox;
    RB_Create: TRadioButton;
    RB_Delete: TRadioButton;
    FE_Flag: TJvFilenameEdit;
    E_Rename: TEdit;
    RB_Rename: TRadioButton;
    RG_Exists: TRadioGroup;
    CB_SaveName: TCheckBox;
    CB_SavePath: TCheckBox;
    GH_Place: TJvGroupHeader;
    GH_Program: TJvGroupHeader;
    GH_Category: TJvGroupHeader;
    GH_Operations: TJvGroupHeader;
    RB_DeletePerm: TRadioButton;
    RB_DeleteDownloaded: TRadioButton;
    CB_Permanently: TCheckBox;
    GH_Common: TJvGroupHeader;
    GH_Rules: TJvGroupHeader;
    RB_RuleEnable: TRadioButton;
    RB_RuleDisable: TRadioButton;
    RB_RuleDelete: TRadioButton;
    CBX_Rules: TComboBox;
    CBX_Destination: TComboBox;
    SB_Destination: TSpeedButton;
    JSD_Destination: TJvSelectDirectory;
    SB_CompileRE: TSpeedButton;
    SB_TestRE: TSpeedButton;
    RB_StartAll: TRadioButton;
    RB_StopAll: TRadioButton;
    CB_SaveStopped: TCheckBox;
    RB_StartStopped: TRadioButton;
    GH_Speed: TJvGroupHeader;
    Label2: TLabel;
    RB_Max: TRadioButton;
    RB_Med: TRadioButton;
    RB_Min: TRadioButton;
    RB_Adjust: TRadioButton;
    CB_SaveSpeed: TCheckBox;
    RB_SpeedLast: TRadioButton;
    RB_StopCategory: TRadioButton;
    RB_Auto: TRadioButton;
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure FormCreate(Sender: TObject);
    procedure RB_CopyClick(Sender: TObject);
    procedure RB_MoveClick(Sender: TObject);
    procedure RB_LaunchClick(Sender: TObject);
    procedure RB_StartClick(Sender: TObject);
    procedure RB_CreateClick(Sender: TObject);
    procedure RB_DeleteClick(Sender: TObject);
    procedure RB_RenameClick(Sender: TObject);
    procedure RG_ExistsClick(Sender: TObject);
    procedure FE_LaunchChange(Sender: TObject);
    procedure CB_SavePathClick(Sender: TObject);
    procedure CB_WaitClick(Sender: TObject);
    procedure E_ParamChange(Sender: TObject);
    procedure CBX_CategoryChange(Sender: TObject);
    procedure CB_FirstClick(Sender: TObject);
    procedure FE_FlagChange(Sender: TObject);
    procedure E_RenameChange(Sender: TObject);
    procedure CB_SaveNameClick(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure RB_DeletePermClick(Sender: TObject);
    procedure RB_DeleteDownloadedClick(Sender: TObject);
    procedure RB_RuleEnableClick(Sender: TObject);
    procedure RB_RuleDisableClick(Sender: TObject);
    procedure RB_RuleDeleteClick(Sender: TObject);
    procedure CBX_RulesChange(Sender: TObject);
    procedure CB_PermanentlyClick(Sender: TObject);
    procedure CBX_DestinationChange(Sender: TObject);
    procedure SB_DestinationClick(Sender: TObject);
    procedure SB_CompileREClick(Sender: TObject);
    procedure SB_TestREClick(Sender: TObject);
    procedure RB_StopCategoryClick(Sender: TObject);
    procedure RB_StartAllClick(Sender: TObject);
    procedure RB_StopAllClick(Sender: TObject);
    procedure RB_StartStoppedClick(Sender: TObject);
    procedure RB_MaxClick(Sender: TObject);
    procedure RB_MedClick(Sender: TObject);
    procedure RB_MinClick(Sender: TObject);
    procedure RB_AdjustClick(Sender: TObject);
    procedure RB_SpeedLastClick(Sender: TObject);
    procedure CB_SaveStoppedClick(Sender: TObject);
    procedure CB_SaveSpeedClick(Sender: TObject);
    procedure RB_AutoClick(Sender: TObject);
  private
    { Private declarations }
    Lang: String;
    FAction: anAction;
    procedure SetLanguage(language: String);
    procedure SetAction(AAction: anAction);
    procedure TranslateToo;
    procedure SetCategories;
    procedure CheckAction(Other: Boolean = true);
  public
    { Public declarations }
    property Language: String write SetLanguage;
    property myAction: anAction read FAction write SetAction;
  end;

var
  AD_AF: TAD_ActionForm = nil;

implementation

{$R *.dfm}

uses
 gnugettext,
 Locales,
 Tokens,
 RegExpr,
 AfterDownload_TestForm;

var
 CanSetAct: Boolean = true;

procedure TAD_ActionForm.SetLanguage(language: String);
begin
 Lang:=language;
 TranslateForm(Self, Language, TranslateToo);
end;

procedure TAD_ActionForm.TranslateToo;
begin
 BitBtn2.Caption:=_('Cancel');
end;

procedure TAD_ActionForm.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
 var
  s: string;
begin
 if ModalResult=mrOK then
  begin
   if FAction.ActType=0 then
    begin
     MessageDlg(_('Please select type of action!'), mtError, [mbOK], 0);
     CanClose:=false;
     Exit;
    end;
   if FAction.ActType in [actStartAll, actStopAll, actStartStopped, actSpeedMax, actSpeedMed, actSpeedMin,
       actSpeedAuto, actSpeedAdj, actSpeedLast, actDownloadedDelete] then
     FAction.Destination:='';
   if not (FAction.Existing in [0..RG_Exists.Items.Count-1]) then
    begin
     MessageDlg(_('Please select type of existing file process!'), mtError, [mbOK], 0);
     ActiveControl:=RG_Exists;
     CanClose:=false;
     Exit;
    end;
   if RB_Copy.Checked or RB_Move.Checked then
    begin
     if not DirectoryExists(FAction.Destination) then
      begin
       MessageDlg(_('Destination folder must exist!'), mtError, [mbOK], 0);
       ActiveControl:=CBX_Destination;
       CanClose:=false;
       Exit;
      end;
    end;
   if RB_Launch.Checked then
    begin
     if not FileExists(FE_Launch.Text) then
      begin
       MessageDlg(_('File to launch must exist!'), mtError, [mbOK], 0);
       ActiveControl:=FE_Launch;
       CanClose:=false;
       Exit;
      end;
    end;
   if E_Rename.Enabled then
    begin
     s:=CompileRE(E_Rename.Text);
     if s<>'' then
      begin
       CanClose:=False;
       ActiveControl:=E_Rename;
       MessageDlg(Format(_('Error in regular expression: %s'), [s]), mtError, [mbOK], 0);
      end;
     Exit;
    end;
  end;
end;

procedure TAD_ActionForm.SetAction(AAction: anAction);
begin
 FAction.Assign(AAction);
 //
 CanSetAct:=false;
 CheckAction(false);
 CanSetAct:=true;
end;

procedure TAD_ActionForm.CheckAction(Other: Boolean = true);
 var
  i: Integer;
  s: string;
begin
 RB_Copy.Checked:=FAction.ActType=actCopy;
 RB_Move.Checked:=FAction.ActType=actMove;
 CBX_Destination.Enabled:=RB_Copy.Checked or RB_Move.Checked;
 SB_Destination.Enabled:=CBX_Destination.Enabled;
 if CBX_Destination.Enabled then
  begin
   //build list of folders
   Assert(Assigned(myInfo), 'INFO must be assigned!');
   for i:=0 to myInfo.Count-1 do
    begin
     s:=IncludeTrailingPathDelimiter(ExtractFilePath(ExtractToken('saveto', myInfo.ValueFromIndex[i])));
     if s<>'' then
      begin
       if CBX_Destination.Items.IndexOf(s)<0 then
         CBX_Destination.Items.Add(s);
      end;
    end;
   //
   if Other then
    begin
     CBX_Destination.Text:='';
     FAction.Destination:='';
    end
   else
    begin
     i:=CBX_Destination.Items.IndexOf(FAction.Destination);
     if i<0 then
       CBX_Destination.Text:=FAction.Destination
     else
       CBX_Destination.ItemIndex:=i;
     CBX_Destination.Hint:=CBX_Destination.Text;
    end;
  end
 else
   CBX_Destination.Text:='';
 CB_SavePath.Enabled:=RB_Copy.Checked or RB_Move.Checked;
 if CB_SavePath.Enabled then
  begin
   if Other then
     CB_SavePath.Checked:=false
   else
     CB_SavePath.Checked:=FAction.Flag;
  end
 else
   CB_SavePath.Checked:=false;
 //
 RB_Launch.Checked:=FAction.ActType=actLaunch;
 FE_Launch.Enabled:=RB_Launch.Checked;
 if FE_Launch.Enabled then
  begin
   if Other then
    begin
     FE_Launch.Text:='';
     FAction.Destination:='';
    end
   else
     FE_Launch.Text:=FAction.Destination;
  end
 else
   FE_Launch.Text:='';
 CB_Wait.Enabled:=RB_Launch.Checked;
 if CB_Wait.Enabled then
  begin
   if Other then
     CB_Wait.Checked:=false
   else
     CB_Wait.Checked:=FAction.Flag;
  end
 else
   CB_Wait.Checked:=false;
 Label1.Enabled:=RB_Launch.Checked;
 E_Param.Enabled:=RB_Launch.Checked;
 if E_Param.Enabled then
  begin
   if Other then
    begin
     E_Param.Text:='';
     FAction.Destination:='';
    end
   else
     E_Param.Text:=FAction.Parameter;
  end
 else
   E_Param.Text:='';
 //
 RB_Start.Checked:=FAction.ActType=actStart;
 RB_StopCategory.Checked:=FAction.ActType=actStopCategory;
 CBX_Category.Enabled:=RB_Start.Checked or RB_StopCategory.Checked;
 if CBX_Category.Enabled then
  begin
   if Other then
     i:=0
   else
    begin
     i:=IndexOfValue(FAction.Destination, CatList);
     if i<0 then
       i:=0;
    end;
   CBX_Category.ItemIndex:=i;
   if i=0 then
     FAction.Destination:=CBX_Category.Text;
  end
 else
   CBX_Category.ItemIndex:=0;
 CB_First.Enabled:=RB_Start.Checked;
 if CB_First.Enabled then
  begin
   if Other then
     CB_First.Checked:=false
   else
     CB_First.Checked:=FAction.Flag;
  end
 else
   CB_First.Checked:=false;
 //
 RB_StartAll.Checked:=FAction.ActType=actStartAll;
 RB_StopAll.Checked:=FAction.ActType=actStopAll;
 CB_SaveStopped.Enabled:=RB_StopAll.Checked;
 if CB_SaveStopped.Enabled then
  begin
   if Other then
     CB_SaveStopped.Checked:=false
   else
     CB_SaveStopped.Checked:=FAction.Flag;
  end
 else
   CB_SaveStopped.Checked:=false;
 //
 RB_StartStopped.Checked:=FAction.ActType=actStartStopped;
 //
 RB_Max.Checked:=FAction.ActType=actSpeedMax;
 RB_Med.Checked:=FAction.ActType=ActSpeedMed;
 RB_Min.Checked:=FAction.ActType=actSpeedMin;
 RB_Auto.Checked:=FAction.ActType=actSpeedAuto;
 RB_Adjust.Checked:=FAction.ActType=actSpeedAdj;
 CB_SaveSpeed.Enabled:=FAction.ActType in [actSpeedMax, ActSpeedMed, actSpeedMin, actSpeedAuto, actSpeedAdj];
 if CB_SaveSpeed.Enabled then
  begin
   if Other then
     CB_SaveSpeed.Checked:=false
   else
     CB_SaveSpeed.Checked:=FAction.Flag;
  end
 else
   CB_SaveSpeed.Checked:=false;
 RB_SpeedLast.Checked:=FAction.ActType=actSpeedLast;
 //
 RB_Create.Checked:=FAction.ActType=actFlagCreate;
 RB_Delete.Checked:=FAction.ActType=actFlagDelete;
 RB_DeletePerm.Checked:=FAction.ActType=actFileDeletePerm;
 FE_Flag.Enabled:=FAction.ActType in [actFlagCreate, actFlagDelete, actFileDeletePerm];
 if FE_Flag.Enabled then
  begin
   if Other then
    begin
     FE_Flag.Text:='';
     FAction.Destination:='';
    end
   else
     FE_Flag.Text:=FAction.Destination;
  end
 else
   FE_Flag.Text:='';
 //
 RB_Rename.Checked:=FAction.ActType=actRename;
 E_Rename.Enabled:=RB_Rename.Checked;
 SB_CompileRE.Enabled:=RB_Rename.Checked;
 SB_TestRE.Enabled:=RB_Rename.Checked;
 if E_Rename.Enabled then
  begin
   if Other then
    begin
     E_Rename.Text:='';
     FAction.Destination:='';
    end
   else
     E_Rename.Text:=FAction.Destination;
  end
 else
   E_Rename.Text:='';
 CB_SaveName.Enabled:=RB_Rename.Checked;
 if CB_SaveName.Enabled then
  begin
   if Other then
     CB_SaveName.Checked:=false
   else
     CB_SaveName.Checked:=FAction.Flag;
  end
 else
   CB_SaveName.Checked:=false;
 //
 RB_DeleteDownloaded.Checked:=FAction.ActType=actDownloadedDelete;
 CB_Permanently.Enabled:=RB_DeleteDownloaded.Checked;
 if CB_Permanently.Enabled then
  begin
   if Other then
     CB_Permanently.Checked:=false
   else
     CB_Permanently.Checked:=FAction.Flag;
  end
 else
   CB_Permanently.Checked:=false;
 //
 RB_RuleEnable.Checked:=FAction.ActType=actRuleEnable;
 RB_RuleDisable.Checked:=FAction.ActType=actRuleDisable;
 RB_RuleDelete.Checked:=FAction.ActType=actRuleDelete;
 CBX_Rules.Enabled:=FAction.ActType in [actRuleEnable, actRuleDisable, actRuleDelete];
 if CBX_Rules.Enabled then
  begin
   CBX_Rules.Items.Clear;
   //build list of rules
   EnterCriticalSection(CS_Rules);
   for i:=0 to myRules.Rules.Count-1 do
     CBX_Rules.Items.Add(myRules.Rules[i].Title);
   LeaveCriticalSection(CS_Rules);
   if Other then
    begin
     CBX_Rules.Text:='';
     FAction.Destination:='';
    end
   else
     CBX_Rules.Text:=FAction.Destination;
  end
 else
   CBX_Rules.Text:='';
 //
 RG_Exists.ItemIndex:=FAction.Existing;
end;

procedure TAD_ActionForm.FormCreate(Sender: TObject);
begin
 TranslateComponent(Self);
 //
 FAction:=anAction.Create(nil);
 //
 SetCategories;
end;

procedure TAD_ActionForm.SetCategories;
 var
  i: Integer;
begin
 CBX_Category.Items.Clear;
 for i:=0 to CatList.Count-1 do
   CBX_Category.Items.Add(CatList.ValueFromIndex[i]);
end;

procedure TAD_ActionForm.RB_CopyClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actCopy;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_MoveClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actMove;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_LaunchClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actLaunch;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_StartClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actStart;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_CreateClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actFlagCreate;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_DeleteClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actFlagDelete;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_RenameClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actRename;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RG_ExistsClick(Sender: TObject);
begin
 FAction.Existing:=RG_Exists.ItemIndex;
end;

procedure TAD_ActionForm.CB_SavePathClick(Sender: TObject);
begin
 if CanSetAct then
   FAction.Flag:=CB_SavePath.Checked;
end;

procedure TAD_ActionForm.FE_LaunchChange(Sender: TObject);
begin
 if CanSetAct then
   FAction.Destination:=FE_Launch.Text;
end;

procedure TAD_ActionForm.CB_WaitClick(Sender: TObject);
begin
 if CanSetAct then
   FAction.Flag:=CB_Wait.Checked;
end;

procedure TAD_ActionForm.E_ParamChange(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.Parameter:=E_Param.Text;
   E_Param.Hint:=ExpandMacros('c:\TestFolder\Testfile.tst', E_Param.Text);
  end;
end;

procedure TAD_ActionForm.CBX_CategoryChange(Sender: TObject);
begin
 if CanSetAct then
   FAction.Destination:=CBX_Category.Text;
end;

procedure TAD_ActionForm.CB_FirstClick(Sender: TObject);
begin
 if CanSetAct then
   FAction.Flag:=CB_First.Checked;
end;

procedure TAD_ActionForm.FE_FlagChange(Sender: TObject);
begin
 if CanSetAct then
  begin
   if FE_Flag.FilterIndex=1 then
    begin
     if ExtractFileExt(FE_Flag.FileName)='.sem' then
       FAction.Destination:=FE_Flag.FileName
     else
      begin
       FAction.Destination:=FE_Flag.FileName+'.sem';
       CanSetAct:=false;
       FE_Flag.FileName:=FAction.Destination;
       CanSetAct:=true;
      end;
    end
   else
     FAction.Destination:=FE_Flag.FileName;
  end;
end;

procedure TAD_ActionForm.E_RenameChange(Sender: TObject);
begin
 if CanSetAct then
   FAction.Destination:=E_Rename.Text;
end;

procedure TAD_ActionForm.CB_SaveNameClick(Sender: TObject);
begin
 if CanSetAct then
   FAction.Flag:=CB_SaveName.Checked;
end;

procedure TAD_ActionForm.FormDestroy(Sender: TObject);
begin
 FAction.Free;
end;

procedure TAD_ActionForm.RB_DeletePermClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actFileDeletePerm;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_DeleteDownloadedClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actDownloadedDelete;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_RuleEnableClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actRuleEnable;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_RuleDisableClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actRuleDisable;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_RuleDeleteClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actRuleDelete;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.CBX_RulesChange(Sender: TObject);
begin
 if CanSetAct then
   FAction.Destination:=CBX_Rules.Text;
end;

procedure TAD_ActionForm.CB_PermanentlyClick(Sender: TObject);
begin
 if CanSetAct then
   FAction.Flag:=CB_Permanently.Checked;
end;

procedure TAD_ActionForm.CBX_DestinationChange(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.Destination:=CBX_Destination.Text;
   CBX_Destination.Hint:=CBX_Destination.Text;
  end;
end;

procedure TAD_ActionForm.SB_DestinationClick(Sender: TObject);
begin
 //JSD_Destination.InitialDir:=CBX_Destination.Text;
 if JSD_Destination.Execute then
  begin
   CBX_Destination.Text:=IncludeTrailingPathDelimiter(JSD_Destination.Directory);
   FAction.Destination:=CBX_Destination.Text;
  end;
end;

procedure TAD_ActionForm.SB_CompileREClick(Sender: TObject);
 var
   s: string;
begin
 s:=CompileRE(E_Rename.Text);
 if s='' then
   MessageDlg(Format(_('Regular expression is valid.'), [s]), mtInformation, [mbOK], 0)
 else
   MessageDlg(Format(_('Error in regular expression: %s'), [s]), mtError, [mbOK], 0);
end;

procedure TAD_ActionForm.SB_TestREClick(Sender: TObject);
 var
   i: Integer;
   s: String;
   myFiles: TStrings;
begin
 s:=CompileRE(E_Rename.Text);
 if s='' then
  begin
   if not Assigned(AD_TF) then
     AD_TF:=TAD_TestForm.Create(Self);
   AD_TF.Language:=Lang;
   AD_TF.Expr:=E_Rename.Text;
   //
   Assert(Assigned(myInfo), 'INFO must be assigned!');
   myFiles:=TStringList.Create;
   for i:=0 to myInfo.Count-1 do
    begin
     myFiles.Add(ExtractFileName(ExtractToken('saveto', myInfo.ValueFromIndex[i])));
    end;
   //
   AD_TF.Files:=myFiles;
   AD_TF.ShowModal;
   FreeAndNil(AD_TF);
   FreeAndNil(myFiles);
  end
 else
   MessageDlg(Format(_('Error in regular expression: %s'), [s]), mtError, [mbOK], 0);
end;

procedure TAD_ActionForm.RB_StopCategoryClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actStopCategory;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_StartAllClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actStartAll;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_StopAllClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actStopAll;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_StartStoppedClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actStartStopped;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_MaxClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actSpeedMax;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_MedClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=ActSpeedMed;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_MinClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actSpeedMin;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_AdjustClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actSpeedAdj;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.RB_SpeedLastClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actSpeedLast;
   CheckAction();
  end;
end;

procedure TAD_ActionForm.CB_SaveStoppedClick(Sender: TObject);
begin
 if CanSetAct then
   FAction.Flag:=CB_SaveStopped.Checked;
end;

procedure TAD_ActionForm.CB_SaveSpeedClick(Sender: TObject);
begin
 if CanSetAct then
   FAction.Flag:=CB_SaveSpeed.Checked;
end;

procedure TAD_ActionForm.RB_AutoClick(Sender: TObject);
begin
 if CanSetAct then
  begin
   FAction.ActType:=actSpeedAuto;
   CheckAction();
  end;
end;

end.
